
//  MineAppraiseTBV.m
//  XJMTechnician
//  Created by Mr.hu on 2017/10/17.
//  Copyright © 2017年 Mr.hu. All rights reserved.

#import "MineAppraiseTBV.h"
#import "MineAppraiseTBVCell.h"

@interface MineAppraiseTBV ()<UITableViewDelegate,UITableViewDataSource>
@property (weak, nonatomic) IBOutlet UITableView *MineAppraiseTable;
@property (nonatomic,strong)  NSArray * muttech_appraise;
@property (nonatomic,strong)  UIView * backview;
@property (nonatomic) NSInteger page;

@end

@implementation MineAppraiseTBV

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController setNavigationBarHidden:NO animated:animated];
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self addLeftBtn:[UIImage imageNamed:@"fanhui"] Action:@selector(backToPrevious)];
    self.title = @"我的评价";
    self.muttech_appraise = [NSArray array];
    
    [self MineIntegerDetailTableView];
    
    self.page=1;
    self.MineAppraiseTable.mj_header = [MJRefreshNormalHeader headerWithRefreshingBlock:^{
        [self MineIntegerDetailTableView];
        [self.MineAppraiseTable.mj_header endRefreshing];
    }];
    
    self.MineAppraiseTable.mj_footer = [MJRefreshAutoNormalFooter footerWithRefreshingBlock:^{
        [self income_detailRequestPulldown:++self.page];
        [self.MineAppraiseTable.mj_footer endRefreshing];
    }];
    self.MineAppraiseTable.mj_footer.automaticallyHidden = YES;
    
    
    
    self.backview = [[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth,ScreenHeight)];
    self.backview.backgroundColor = RGBA(243, 243, 243, 1);
    [self.view addSubview:self.backview];
    UIImageView * topimageview = [[UIImageView alloc]init];
    [topimageview setImage:[UIImage imageNamed:@"no_colle"]];
    [self.backview addSubview:topimageview];
    [topimageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(150);
        make.size.mas_equalTo(CGSizeMake(120, 120));
        make.centerX.equalTo(self.view);
    }];
    
    UILabel * sizelabe = [[UILabel alloc]init];
    sizelabe.text = @"暂无评价";
    sizelabe.font = [UIFont systemFontOfSize:16];
    sizelabe.textColor = [UIColor grayColor];
    sizelabe.textAlignment = NSTextAlignmentCenter;
    [self.backview addSubview:sizelabe];
    [sizelabe mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(topimageview.mas_bottom).offset(10);
        make.centerX.equalTo(self.view);
        make.size.mas_equalTo(CGSizeMake(100, 20));
    }];
    
}


- (void)income_detailRequestPulldown:(NSInteger)page{
    
    [self.MineAppraiseTable registerNib:[UINib nibWithNibName:@"MineAppraiseTBVCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MineAppraiseTBVCell"];
    
    [XJHttpClass receiveTechCommenttoken:[XJToolClass getToken] page:[NSString stringWithFormat:@"%ld",page] andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            [self.MineAppraiseTable.mj_footer endRefreshingWithNoMoreData];
        }else{
            self.backview.hidden = YES;
            NSDictionary * dictdata = response[@"data"];
            
            if ([dictdata isKindOfClass:[NSDictionary class]]) {
                self.muttech_appraise = dictdata[@"appraise_list"];
            }
            [self.MineAppraiseTable reloadData];
        }
    }];
    
}

- (void)MineIntegerDetailTableView{
    
    self.MineAppraiseTable.delegate = self;
    self.MineAppraiseTable.dataSource = self;
    self.MineAppraiseTable.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    [self.MineAppraiseTable registerNib:[UINib nibWithNibName:@"MineAppraiseTBVCell" bundle:[NSBundle mainBundle]] forCellReuseIdentifier:@"MineAppraiseTBVCell"];
    
    [XJHttpClass receiveTechCommenttoken:[XJToolClass getToken] page:@"1" andFinishblock:^(id response, NSString *errStr) {
        
        if (errStr) {
            self.backview.hidden = NO;
        }else{
            self.backview.hidden = YES;
            NSDictionary * dictdata = response[@"data"];
            
            if ([dictdata isKindOfClass:[NSDictionary class]]) {
                self.muttech_appraise = dictdata[@"appraise_list"];
            }
            [self.MineAppraiseTable reloadData];
        }
    }];
}

#pragma mark - TableViewDatasource
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.muttech_appraise.count >0?self.muttech_appraise.count:0;
}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    MineAppraiseTBVCell * friend=[tableView dequeueReusableCellWithIdentifier:@"MineAppraiseTBVCell" forIndexPath:indexPath];
    
    [friend setdata:self.muttech_appraise[indexPath.row]];
    
    return friend;
}

#pragma mark TableViewDelegate
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    return 70;
}

-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 0;
}


-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    //当手指离开某行时，就让某行的选中状态消失
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
